package com.andong.service.impl;

import com.andong.domain.entity.Admin;
import com.andong.domain.entity.Coach;
import com.andong.domain.entity.Student;
import com.andong.domain.pojo.Result;
import com.andong.domain.vo.CountVO;
import com.andong.domain.vo.StatisticsGenderVO;
import com.andong.domain.vo.StatisticsTypeVO;
import com.andong.mapper.StatisticsMapper;
import com.andong.service.StatisticsService;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * ClassName: StatisticsServiceImpl
 *
 * @author XHU_WHY
 * @version V1.0
 * @since 2024/2/26 17:25
 */
@Service
public class StatisticsServiceImpl implements StatisticsService {
    @Resource
    private StatisticsMapper statisticsMapper;
    @Override
    public Result getStudentByType() {
        List<StatisticsTypeVO> list = statisticsMapper.getStudentByType();
        return Result.success(list);
    }

    @Override
    public Result getStudentByGender() {
        List<StatisticsGenderVO> list = statisticsMapper.getStudentByGender();
        return Result.success(list);
    }

    @Override
    public Result getCoachByType() {
        List<StatisticsTypeVO> list = statisticsMapper.getCoachByType();
        return Result.success(list);
    }

    @Override
    public Result getCoachByGender() {
        List<StatisticsGenderVO> list = statisticsMapper.getCoachByGender();
        return Result.success(list);
    }

    @Override
    public Result getCount() {
        Long studentCount = Db.count(Student.class);
        Long coachCount = Db.count(Coach.class);
        Long adminCount = Db.count(Admin.class);
        CountVO countVO = new CountVO(studentCount, coachCount, adminCount);
        return Result.success(countVO);
    }

    @Override
    public Result getStage() {
        List<StatisticsTypeVO> list = statisticsMapper.getStage();
        return Result.success(list);
    }
}
